package com.unicom.proxy.staticproxy;

import com.unicom.proxy.jdkproxy.UserService;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2022/1/3 18:02
 * Description:
 */
public class StaticProxy {

    private UserService userService;

    public StaticProxy(UserService userService) {
        this.userService = userService;
    }

    public void add() {
        // 执行非业务逻辑
        before();
        // 执行业务逻辑
        userService.add();
        after();
    }

    public void delete() {
        before();
        userService.delete();
        after();
    }

    public void update() {
        before();
        userService.update();
        after();
    }


    // 非业务逻辑
    public void before() {
        System.out.println("----目标方法执行: before------");
    }

    public void after() {
        System.out.println("----目标方法执行: after------");
    }
}
